home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / jpi / spriteed.bas < prev    next >
BASIC Source File  |  1998-01-04  |  11KB  |  402 lines

  1. Attribute VB_Name = "Module1"
  2. Global Const PICDEFFILE$ = "PictureDefs.Dat"
  3. Global Const SPRITEDEFFILE$ = "Sprites.Dat"
  4. Global Const CurrVers$ = "ION FORMAT VERSION: 1.0"
  5. Type Spfs
  6.   FrameName As String
  7.   picname As String
  8.   Duration As Integer
  9. End Type
  10. Type SpfGs
  11.   GroupRepeats As Boolean
  12.   SpriteGroupName As String
  13.   SpriteFrames(100) As Spfs
  14.   FrameMax As Integer
  15. End Type
  16. Type Sps
  17.   SpriteName As String
  18.   SpriteFrameGroups(20) As SpfGs
  19.   GroupMax As Integer
  20. End Type
  21. Global Sprites(200) As Sps
  22. Type pcz
  23.   Masked As Boolean
  24.   GraphicsLib As String
  25.   picname As String
  26.   X As Integer
  27.   Y As Integer
  28.   Width As Integer
  29.   Height As Integer
  30. End Type
  31. Global Picz(500) As pcz
  32. Global PicMax As Integer
  33. Global SpriteMax As Integer
  34. Type Lbs
  35.   LibName As String
  36.   picname As String
  37. End Type
  38. Global GraphicLibs(100) As Lbs
  39. Global LibMax As Integer
  40. Sub LoadPicInfo()
  41. On Error GoTo ERR1
  42. PicMax = 0
  43. Open PICDEFFILE$ For Input As #1
  44.   Line Input #1, a$
  45.   If a$ <> CurrVers$ Then
  46.     Call CurrVersError
  47.   End If
  48.   Do
  49.     Line Input #1, a$
  50.     If a$ = "[ENDOFFILE]" Then Exit Do
  51.     If a$ = "[PICDEF]" Then
  52.       'increments the current picture num
  53.       PicMax = PicMax + 1
  54.       
  55.       'Picture name
  56.       Line Input #1, a$
  57.       fval$ = GetPropertyValue(a$)
  58.       Picz(PicMax).picname = fval$
  59.       
  60.       'Graphics Library of the pic
  61.       Line Input #1, a$
  62.       fval$ = GetPropertyValue(a$)
  63.       Picz(PicMax).GraphicsLib = fval$
  64.       
  65.       
  66.       'X
  67.       Line Input #1, a$
  68.       fval$ = GetPropertyValue(a$)
  69.       Picz(PicMax).X = Val(fval$)
  70.       
  71.       'Y
  72.       Line Input #1, a$
  73.       fval$ = GetPropertyValue(a$)
  74.       Picz(PicMax).Y = Val(fval$)
  75.       
  76.       'Width
  77.       Line Input #1, a$
  78.       fval$ = GetPropertyValue(a$)
  79.       Picz(PicMax).Width = Val(fval$)
  80.       
  81.       'Height
  82.       Line Input #1, a$
  83.       fval$ = GetPropertyValue(a$)
  84.       Picz(PicMax).Height = Val(fval$)
  85.     
  86.     End If
  87.   Loop
  88. Close #1
  89. Exit Sub
  90. ERR1:
  91. Close #1
  92. PicMax = 0
  93. End Sub
  94. Sub CurrVersError()
  95. MsgBox "Wrong file version"
  96. End
  97. End Sub
  98. Public Function GetPropertyValue(TextString) As String
  99. GetPropertyValue = Right$(TextString, Len(TextString) - InStr(1, TextString, " "))
  100. If InStr(1, TextString, " ") = 0 Then GetPropertyValue = ""
  101. End Function
  102.  
  103. Sub LoadAll()
  104. Call LoadPicInfo
  105. Call LoadSpriteInfo
  106. End Sub
  107. Sub LoadSpriteInfo()
  108. On Error GoTo ERR2
  109. SpriteMax = 0
  110. Open SPRITEDEFFILE$ For Input As #1
  111.   Line Input #1, a$
  112.   If a$ <> CurrVers$ Then
  113.     Call CurrVersError
  114.   End If
  115.   Do
  116.     Line Input #1, a$
  117.     If a$ = "[ENDOFFILE]" Then Exit Do
  118.     If a$ = "[SPRITEDEF]" Then
  119.       'increments the current sprite num
  120.       SpriteMax = SpriteMax + 1
  121.       
  122.       'name of the sprite
  123.       Line Input #1, a$
  124.       fval$ = GetPropertyValue(a$)
  125.       Sprites(SpriteMax).SpriteName = fval$
  126.       
  127.       'reset the group number
  128.       Sprites(SpriteMax).GroupMax = 0
  129.       Do
  130.         Line Input #1, a$
  131.         If a$ = "[ENDSPRITEDEF]" Then Exit Do
  132.         If a$ = "-FRAMEGROUP-" Then
  133.           Sprites(SpriteMax).GroupMax = Sprites(SpriteMax).GroupMax + 1
  134.           'Group name
  135.           Line Input #1, a$
  136.           fval$ = GetPropertyValue(a$)
  137.           Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteGroupName = fval$
  138.           'group Repeats
  139.           Line Input #1, a$
  140.           fval$ = GetPropertyValue(a$)
  141.           If fval$ = "True" Then
  142.             YesNo = True
  143.           Else
  144.             YesNo = False
  145.           End If
  146.           Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).GroupRepeats = YesNo
  147.           FrameMax = 0
  148.           Do
  149.             Line Input #1, a$
  150.             If a$ = "-ENDFRAMEGROUP-" Then Exit Do
  151.             If a$ = "-FRAME-" Then
  152.               FrameMax = FrameMax + 1
  153.               Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).FrameMax = FrameMax
  154.               'Frame name
  155.               Line Input #1, a$
  156.               fval$ = GetPropertyValue(a$)
  157.               Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteFrames(FrameMax).FrameName = fval$
  158.               
  159.               'Frame duration
  160.               Line Input #1, a$
  161.               fval$ = GetPropertyValue(a$)
  162.               Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteFrames(FrameMax).Duration = Val(fval$)
  163.               
  164.               'Frame picture name
  165.               Line Input #1, a$
  166.               fval$ = GetPropertyValue(a$)
  167.               Sprites(SpriteMax).SpriteFrameGroups(Sprites(SpriteMax).GroupMax).SpriteFrames(FrameMax).picname = fval$
  168.             End If
  169.           Loop
  170.         End If
  171.       Loop
  172.     End If
  173.   Loop
  174. Close #1
  175. Exit Sub
  176. ERR2:
  177. Close #1
  178. SpriteMax = 0
  179. End Sub
  180. Sub updateSpritelist()
  181. currindex = Form1.List1.ListIndex
  182. Form1.List1.Clear
  183. Form1.List1.AddItem "[NewSprite]"
  184. For i = 1 To SpriteMax
  185.   Form1.List1.AddItem Sprites(i).SpriteName
  186. Next i
  187. Form1.List1.ListIndex = currindex
  188. Form1.Label1.Caption = Form1.List1.List(Form1.List1.ListIndex)
  189. End Sub
  190. Sub UpdateSpriteProperties()
  191. snum = Form1.List1.ListIndex
  192. If snum > 0 Then
  193.   Form1.Text1.Text = Sprites(snum).SpriteName
  194. Else
  195.   Form1.Text1.Text = ""
  196. End If
  197. Form1.Label1.Caption = Form1.List1.List(Form1.List1.ListIndex)
  198. End Sub
  199.  
  200. Sub UpdateGroupProperties()
  201. snum = Form1.List1.ListIndex
  202. gnum = Form1.List2.ListIndex
  203.  
  204. If snum > 0 Then
  205.   Form1.Text2.Text = Sprites(snum).SpriteFrameGroups(gnum).SpriteGroupName
  206.   If Sprites(snum).SpriteFrameGroups(gnum).GroupRepeats = True Then
  207.     Form1.Check1.Value = 1
  208.   Else
  209.     Form1.Check1.Value = 0
  210.   End If
  211.  
  212. Else
  213.   
  214.   Form1.Text2.Text = ""
  215.   Form1.Check1.Value = 0
  216. End If
  217.  
  218. End Sub
  219.  
  220. Sub UpdateGroupList()
  221. currindex = Form1.List2.ListIndex
  222. Form1.List2.Clear
  223. Form1.List2.AddItem "[NewGroup]"
  224. snum = Form1.List1.ListIndex
  225. For i = 1 To Sprites(snum).GroupMax
  226.   Form1.List2.AddItem Sprites(snum).SpriteFrameGroups(i).SpriteGroupName
  227. Next i
  228. Form1.List2.ListIndex = currindex
  229. End Sub
  230.  
  231. Sub UpdateFrameList()
  232. currindex = Form1.List3.ListIndex
  233. Form1.List3.Clear
  234. Form1.List3.AddItem "[NewFrame]"
  235. snum = Form1.List1.ListIndex
  236. gnum = Form1.List2.ListIndex
  237. For i = 1 To Sprites(snum).SpriteFrameGroups(gnum).FrameMax
  238.   Form1.List3.AddItem Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(i).FrameName
  239. Next i
  240. Form1.List3.ListIndex = currindex
  241. End Sub
  242.  
  243. Sub UpdateFrameProperties()
  244. snum = Form1.List1.ListIndex
  245. gnum = Form1.List2.ListIndex
  246. fnum = Form1.List3.ListIndex
  247. If snum > 0 Then
  248.   Form1.Text4.Text = Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(fnum).Duration
  249.   For i = 0 To Form1.List4.ListCount - 1
  250.     If Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(fnum).picname = Form1.List4.List(i) Then
  251.       Form1.List4.ListIndex = i
  252.       Exit For
  253.     End If
  254.   Next i
  255.   Form1.Text3.Text = Sprites(snum).SpriteFrameGroups(gnum).SpriteFrames(fnum).FrameName
  256. Else
  257.   Form1.Text3.Text = ""
  258. End If
  259.  
  260. End Sub
  261. Sub updateSpritenamelist()
  262. On Error Resume Next
  263. Form1.List4.Clear
  264. For i = 1 To PicMax
  265.   Form1.List4.AddItem Picz(i).picname
  266. Next i
  267. For i = 0 To PicMax - 1
  268.   If Form1.List4.List(i) = Sprites(Form1.List5.ListIndex).SpriteFrameGroups(Form1.List2.ListIndex).SpriteFrames(Form1.List3.ListIndex).picname Then
  269.     Form1.List4.ListIndex = i
  270.     Exit For
  271.   End If
  272. Next i
  273. End Sub
  274. Sub LoadGraphicLibs()
  275. On Error GoTo err
  276. LibMax = 0
  277. Open "GraphicLibs.Dat" For Input As #1
  278. Line Input #1, a$
  279. Do
  280.   Line Input #1, a$
  281.   If a$ = "[ENDOFFILE]" Then Exit Do
  282.   If a$ = "[GRAPHICSLIBRARYDEF]" Then
  283.     LibMax = LibMax + 1
  284.     Line Input #1, a$
  285.     fval$ = GetPropertyValue(a$)
  286.     GraphicLibs(LibMax).LibName = fval$
  287.     Line Input #1, a$
  288.     fval$ = GetPropertyValue(a$)
  289.     GraphicLibs(LibMax).picname = fval$
  290.   End If
  291. Loop
  292. Close #1
  293. Exit Sub
  294. err:
  295. Close #1
  296. Exit Sub
  297. End Sub
  298. Sub UpdatePicList()
  299. CurrIndx = Form1.List5.ListIndex
  300. Form1.List5.Clear
  301. Form1.List5.AddItem "[NewPic]"
  302. For i = 1 To PicMax
  303.   Form1.List5.AddItem Picz(i).picname
  304. Next i
  305. Form1.List5.ListIndex = CurrIndx
  306. End Sub
  307. Sub UpdateLibList()
  308. On Error Resume Next
  309. Fo